package com.qf.file.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

/**
 * @author 30909
 */
@Configuration
public class MultipartConfig {

    @Bean
    public MultipartConfigElement multipartConfigElement() {

        MultipartConfigFactory factory = new MultipartConfigFactory();
        //限制200M
        DataSize dataSize = DataSize.ofBytes(200 * 1024 * 1024);

        factory.setMaxRequestSize(dataSize);

        factory.setMaxFileSize(dataSize);

        return factory.createMultipartConfig();
    }
}
